<template>
  <div class="h-full">
    <DataScreenHeader
      :title="`周生产看板(${nowMonth}周)`"
      :showMonth="false"
      classes=""
    />
    <div
      style="
        height: calc(100% - 100px);
        padding: 10px 20px 20px;
        overflow: hidden;
      "
    >
      <dv-border-box10 class="overflow-hidden">
        <div
          dv-bg
          class="flex justify-center items-center m-[30px]"
          style="flex-direction: column"
        >
          <div class="title mb-2">
            <span class="text">周生产完成数量</span>
          </div>
          <ScrollTableDemo :planBIDTOS="planBIDTOS" :tableColumnNum="12" />
        </div>
      </dv-border-box10>
    </div>
  </div>
</template>

<script setup lang="ts">
import { BorderBox10 as DvBorderBox10 } from "@kjgl77/datav-vue3";
defineOptions({
  name: "DATASCREENMES01",
  inheritAttrs: false,
});

const props = defineProps({
  planBIDTOS: {
    type: Array,
    default: () => [],
  },
  refreshRate: {
    type: Number,
    default: () => 0,
  },
});

const emit = defineEmits(["get-info"]);
const { planBIDTOS, refreshRate } = toRefs(props);

let timer: any = ref(null);

const nowMonth = ref();
const monthTimer = ref();
monthTimer.value = setInterval(() => {
  setNowTimes();
}, 0);

function setNowTimes() {
  const currentDate: any = new Date();
  const weekNumber = Math.ceil(
    (currentDate - new Date(currentDate.getFullYear(), 0, 1)) /
      (7 * 24 * 60 * 60 * 1000)
  );
  nowMonth.value = weekNumber;
}

onMounted(() => {
  if (refreshRate.value) {
    timer.value = setInterval(() => {
      emit("get-info");
    }, refreshRate.value * 1000);
  }
});

onBeforeUnmount(() => {
  clearInterval(timer.value);
  timer.value = null;
  clearInterval(monthTimer.value);
  monthTimer.value = null;
});
</script>

<style lang="scss" scoped>
.title {
  background-image: url(@/assets/images/screen/title.png);
  background-repeat: no-repeat;
  background-size: cover;
  background-position: left;
  width: 400px;
  height: 50px;
  line-height: 50px;
  align-self: flex-start;
  .text {
    font-size: 30px;
    line-height: 32px;
    padding-left: 30px;
    font-weight: 600;
    writing-mode: horizontal-tb;
    text-orientation: upright;
    color: transparent;
    background: linear-gradient(
        0deg,
        rgb(255, 255, 255) 0px,
        rgb(255, 255, 255) 100%
      )
      text;
    clip-path: inset(1px);
  }
}
</style>
